package main

import (
	"bytes"
	"encoding/binary"
	"fmt"
)

func main() {
	buf := new(bytes.Buffer)
	//pi := math.Pi

	_ = binary.Write(buf, binary.LittleEndian, int8(2))

	fmt.Println(buf.Bytes())  //  [2]  将data序列化成字节流写入w

	_ = binary.Write(buf, binary.LittleEndian, int32(2))

	fmt.Println(buf.Bytes())  //  [2 2 0 0 0]

	_ = binary.Write(buf, binary.LittleEndian, []byte("abc"))
	//等价于下面一行代码
	//_ = binary.Write(buf, binary.LittleEndian, []byte{'a','b','c'})

	fmt.Println(buf.Bytes())  //  [2 2 0 0 0 97 98 99]
}